from playwright.sync_api import expect, Page, Playwright,sync_playwright

class RegisterPage:
    def __init__(self,page:Page):
        self.page = page
        self.iframe = self.page.frame_locator('#popup_reg_frame')
        self.username = self.iframe.locator('#j-username')
        self.password  = self.iframe.locator('#j-password')
        self.re_password = self.iframe.locator('#j-passwordveri')
        self.name = self.iframe.locator('#j-realname')
        self.idcard = self.iframe.locator('#j-idcard')

        self.agree_check = self.iframe.locator('#reg_eula_agree')

        self.register_button = self.iframe.locator('.ptlogin_register')


    def register(self,username,password,re_password,name,idcard):
        self.username.clear()
        self.username.fill(username)
        self.password.fill(password)
        self.re_password.fill(re_password)
        self.name.fill(name)
        self.idcard.fill(idcard)
        self.agree_check.check()
        self.register_button.click()


    def navigate(self):
        self.page.goto('/')

    def username_empty(self):
        self.username.clear()
        self.agree_check.click()

